﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.popups.fountain {
    import flash.events.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.models.world.vos.actors.machines.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.controllers.startup.*;
    import net.wooga.pets.models.world.*;

    public class FountainRewardPopupMediator extends AbstractFountainPopupMediator {

        public var world:WorldModel;
        public var slots:RoomSlotsModel;
        public var gameViewModel:GameViewModel;

        override public function onRegister():void{
            ticker.pause = true;
            l(("onRegister: " + this.onRegister));
            super.onRegister();
            addLabel("rewardSubHeader myriadProFont", "fountain_thanks_headline", null, _content);
            addLabel("rewardLabel myriadProFont", "fountain_thanks_story", null, _content);
            addActionButton("fountain_button_share_pow", _content);
            addReward(ProtocolConstants.XP, this.view.data.xp, _rewardContent);
            _rewardCount++;
            addReward(ProtocolConstants.COINS, this.view.data.coins, _rewardContent);
            _rewardCount++;
            adjustRewardContentWidth(_rewardCount);
            this.checkKindergarten();
        }
        private function checkKindergarten():void{
            var _local2:String;
            var _local3:IRoom;
            var _local4:KindergartenMachineVO;
            var _local1:Boolean = this.world.hasAreaType(GameConstants.TYPE_KINDERGARTEN);
            if (_local1){
                _local2 = this.world.getRoomIdsOfType(GameConstants.TYPE_KINDERGARTEN)[0];
                _local3 = (this.world.getRoomById(_local2) as IRoom);
                _local4 = (_local3.machine as KindergartenMachineVO);
                if (!_local4.isFree){
                    addLabel("kindergartenLabel myriadProFont red", "fountain_thanks_kindergarten_full", null, _content);
                } else {
                    addLabel("kindergartenLabel myriadProFont", "fountain_thanks_kindergarten_free", null, _content);
                };
            };
        }
        override protected function onClick(_arg1:MouseEvent):void{
            this.zoomOut();
            var _local2:String = this.view.data.patientId;
            var _local3:String = this.view.data.patientType;
            var _local4:Object = {type:GameConstants.REGENERATION_FINALIZED, patientId:_local2, patientType:_local3};
            var _local5:InfoEvent = new InfoEvent(EventConstants.POST_ON_WALL, null, _local4);
            dispatch(_local5);
            super.onClick(_arg1);
        }
        override protected function onCancel(_arg1:MouseEvent):void{
            this.zoomOut();
            super.onCancel(_arg1);
        }
        override protected function close():void{
            super.close();
            var _local1:String = this.world.getRoomIdsOfType(GameConstants.TYPE_FOUNTAIN)[0];
            dispatch(new InfoEvent(EventConstants.GET_ROOM_ITEMS, _local1));
        }
        private function zoomOut():void{
            this.gameViewModel.setGameScaleByIndex(GameViewModel.SCALE_4X4);
        }
        private function get view():FountainRewardPopupView{
            return ((viewComponent as FountainRewardPopupView));
        }

    }
}//package net.wooga.pets.views.popups.fountain 
